var t = getApp();

Page({
    data: {
        successShow: !1,
        errorShow: !1,
        subject: null,
        integral: 0,
        vid: 0,
        integral_name: "积分"
    },
    onLoad: function(t) {
        console.log(t), t.vid && (this.data.vid = t.vid, this.getSubject());
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    getSubject: function() {
        var a = this, e = t.getNetAddresss("plugin.answer-reward.api.index.get-subject");
        t._getNetWork({
            url: e,
            data: {
                vid: this.data.vid
            },
            success: function(t) {
                var e = t.data;
                1 == e.result && (1 != e.data.status ? wx.showToast({
                    title: "本视频你已获得积分奖励",
                    icon: "none",
                    duration: 1500
                }) : null != e.data.subject && a.setData({
                    integral_name: e.data.integral_name,
                    subject: e.data.subject
                }));
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    reward: function(a) {
        var e = this, n = a.currentTarget.dataset.id;
        console.log(a);
        var s = t.getNetAddresss("plugin.answer-reward.api.index.index");
        t._getNetWork({
            url: s,
            data: {
                vid: this.data.vid,
                subject_id: this.data.subject.id,
                answer_id: n
            },
            success: function(t) {
                var a = t.data;
                1 != a.result ? e.setData({
                    errorShow: !0
                }) : 0 == a.data.status ? wx.showToast({
                    title: a.msg,
                    icon: "none",
                    duration: 1500
                }) : 1 == a.data.status && e.setData({
                    successShow: !0,
                    integral: a.data.integral
                });
            }
        });
    },
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    gotoBack: function() {
        this.setData({
            errorShow: !1,
            successShow: !1
        }), wx.navigateBack();
    }
});